package com.bosicloud.cmb.ibp.microplatform.commom.vo;


import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotBlank;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import java.util.List;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class DeployServiceVO {

    @NotNull
    @NotBlank(message = "环境不能为空")
    String envName;
    @NotNull
    @NotBlank(message = "集群名不能为空")
    String clusterName;
    @NotNull
    @Min(1)
    @Max(65535)
    Integer listenerPort;
    @NotNull
    @Min(1)
    @Max(100)
    Integer expectInstanceCount;
    @Pattern(regexp ="^[a-zA-z][A-Za-z0-9-]{0,15}",message = "服务名必须以字母开头只能包含数字和-")
    @Length(max = 16, message = "服务名称最大长度为16")
    @NotBlank(message = "服务名称不能为空")
    String serviceName;
    @NotNull
    @NotBlank(message = "服务类型不能为空")
    String serviceType;
    @NotNull
    @NotBlank(message = "docker镜像路径不能为空")
    String dockerImagePath;
    @Pattern(regexp = "^/.*", message = "部署路径必须以/开头")
    @NotBlank(message = "Deploy Path 不能为空")
    String deployPath;
    @NotNull
    @NotBlank(message = "服务协议不能为空")
    String serviceProtocol;
    String taskRole;
    @NotNull
    @Min(128)
    @Max(1024 * 64)
    Integer containerMemory;
    @NotNull
    @Min(10)
    @Max(1024 * 8)
    Integer containerCpu;
    @NotNull
    @Min(1)
    @Max(65535)
    Integer containerPort;
    @NotNull
    @NotBlank(message = "服务健康path不能为空")
    String healthPath;
    @NotNull
    @Min(10)
    @Max(60)
    Integer healthQueryDelay;
    Integer createUser;
    List<EnvArguments> argumentsList;

    @Data
    @Builder
    @NoArgsConstructor
    @AllArgsConstructor
    public static class EnvArguments {
        String argumentsKey;
        String argumentsValue;
    }

}
